﻿using System;
using System.Windows.Forms;

namespace Money.Plugins.Import.RbsImport
{
    public partial class ConfigurationForm : Form
    {
        private Configuration _configuration;

        public ConfigurationForm(Configuration config)
        {
            InitializeComponent();

            _configuration = config;

            checkBox1.Checked = _configuration.ApplyNameTidy;
            tbParser.Text = _configuration.MatchString;
            tbFieldCount.Text = _configuration.FieldCount.ToString();
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            // TODO update all of the changed fields into the configuration settings
            _configuration.ApplyNameTidy = checkBox1.Checked;
            _configuration.FieldCount = Convert.ToInt16(tbFieldCount.Text);
            _configuration.MatchString = tbParser.Text;
            
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
